package middleware

import (
	"database/sql"

	"github.com/gin-gonic/gin"
)

const (
	DatabaseStateKey = "db"
)

func DataBaseMiddleware(db *sql.DB) gin.HandlerFunc {
	return func(ctx *gin.Context) {
		// Stores the database connection in the Gin context.
		ctx.Set(DatabaseStateKey, db)

		// Continue to the next handler
		ctx.Next()
	}
}
